package com.aspose.cells;

import java.util.Iterator;

class zug {
   private Workbook a;
   private Worksheet b;
   private zol c;

   zug(zol var1) {
      this.c = var1;
      this.a = var1.b;
      this.b = var1.a;
   }

   void a(zcfx var1, zuf var2) throws Exception {
      if (this.a()) {
         var1.b("extLst");
         var2.b(var1);
         this.a(var1);
         this.a(var1, 1);
         this.a(var1, 2);
         this.a(var1, "{7E03D99C-DC04-49d9-9315-930204A7B6E9}");
         var1.b();
      }
   }

   private void a(zcfx var1, String var2) throws Exception {
      if (this.b.g != null && this.b.g.f != null) {
         String var3 = (String)this.b.g.f.get(var2);
         var1.d(var3);
      }

   }

   private void a(zcfx var1, int var2) throws Exception {
      if (this.c.y != null) {
         String var3 = null;
         String var4 = null;
         String var5 = null;
         switch(var2) {
         case 1:
            var3 = "{A8765BA9-456A-4dab-B4F3-ACF838C121DE}";
            var4 = "x14";
            var5 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
            break;
         case 2:
            var3 = "{3A4CF648-6AED-40f4-86FF-DC5316D8AED3}";
            var5 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
            var4 = "x15";
         }

         zqe var6 = (zqe)this.c.y.get(var3);
         if (var6 != null) {
            var1.b("ext");
            var1.a("uri", var3);
            var1.a("xmlns", var4, (String)null, var5);
            if (var2 == 2) {
               var4 = "x14";
            }

            var1.a(var4, "slicerList", false);
            if (var2 == 2) {
               var1.a("xmlns", var4, (String)null, "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
            }

            var1.a(var4, "slicer", false);
            var1.a("r:id", var6.c);
            var1.b();
            var1.b();
            var1.b();
         }
      }
   }

   private boolean a() {
      this.b.getSparklineGroupCollection().b();
      if (this.b.g != null && this.b.g.f != null && this.b.g.f.size() > 0) {
         return true;
      } else if (this.b.getSparklineGroupCollection().getCount() > 0) {
         return true;
      } else if (this.b()) {
         return true;
      } else {
         return this.c.y != null && this.c.y.size() > 0;
      }
   }

   private boolean b() {
      return this.b.getConditionalFormattings().b();
   }

   private void a(zcfx var1) throws Exception {
      if (this.b.getSparklineGroupCollection().getCount() != 0) {
         var1.b("ext");
         var1.a("uri", "{05C60535-1F16-4fd2-B633-F4F36F0B64E0}");
         var1.a("xmlns:x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
         var1.b("x14:sparklineGroups");
         var1.a("xmlns:xm", "http://schemas.microsoft.com/office/excel/2006/main");
         Iterator var2 = this.b.getSparklineGroupCollection().iterator();

         while(var2.hasNext()) {
            SparklineGroup var3 = (SparklineGroup)var2.next();
            this.a(var1, var3);
         }

         var1.b();
         var1.b();
      }
   }

   private void a(zcfx var1, SparklineGroup var2) throws Exception {
      var1.b("x14:sparklineGroup");
      this.b(var1, var2);
      this.a(var1, "colorSeries", var2.getSeriesColor());
      this.a(var1, "colorNegative", var2.getNegativePointsColor());
      this.a(var1, "colorAxis", var2.getHorizontalAxisColor());
      this.a(var1, "colorMarkers", var2.getMarkersColor());
      this.a(var1, "colorFirst", var2.getFirstPointColor());
      this.a(var1, "colorLast", var2.getLastPointColor());
      this.a(var1, "colorHigh", var2.getHighPointColor());
      this.a(var1, "colorLow", var2.getLowPointColor());
      String var3 = var2.getHorizontalAxisDateRange();
      if (var3 != null) {
         var1.b("xm:f", var3);
      }

      var1.b("x14:sparklines");
      Iterator var4 = var2.getSparklineCollection().iterator();

      while(var4.hasNext()) {
         Sparkline var5 = (Sparkline)var4.next();
         this.a(var1, var5);
      }

      var1.b();
      var1.b();
   }

   private void a(zcfx var1, Sparkline var2) throws Exception {
      var1.b("x14:sparkline");
      String var3 = var2.getDataRange();
      if (var3 != null && !"".equals(var3)) {
         var1.b("xm:f", var2.getDataRange());
      }

      var1.b("xm:sqref", CellsHelper.cellIndexToName(var2.getRow(), var2.getColumn()));
      var1.b();
   }

   private void a(zcfx var1, String var2, CellsColor var3) throws Exception {
      zakp var4 = var3.a;
      var1.b("x14:" + var2);
      if (var4.b() == 4) {
         var1.a("theme", zase.y(var4.d()));
         if (var4.f() != 0.0D) {
            var1.a("tint", this.a(var4.f()));
         }
      } else if (var4.b() == 2) {
         var1.a("rgb", "FF" + zase.a(Color.fromArgb(var4.d())));
         if (var4.f() != 0.0D) {
            var1.a("tint", this.a(var4.f()));
         }
      } else {
         var1.a("rgb", "FF" + zase.a(var3.getColor()));
      }

      var1.b();
   }

   private String a(double var1) {
      double var3 = 1.0E-4D;
      double var5;
      if (var1 < 0.0D) {
         var5 = var1 + 0.499984740745262D;
         if (Math.abs(var5) < var3) {
            return "-0.499984740745262";
         }

         if (var5 > 0.0D && Math.abs(var1 + 0.249977111117893D) < var3) {
            return "-0.249977111117893";
         }
      } else {
         var5 = var1 - 0.3999755851924192D;
         if (Math.abs(var5) < var3) {
            return "0.39997558519241921";
         }

         if (var5 > 0.0D) {
            var5 = var1 - 0.499984740745262D;
            if (Math.abs(var5) < var3) {
               return "0.499984740745262";
            }

            if (var5 > 0.0D && Math.abs(var1 - 0.7999816888943144D) < var3) {
               return "0.79998168889431442";
            }
         } else {
            var5 = var1 - 0.3499862666707358D;
            if (Math.abs(var5) < var3) {
               return "0.34998626667073579";
            }

            if (var5 < 0.0D && Math.abs(var1 - 0.249977111117893D) < var3) {
               return "0.249977111117893";
            }
         }
      }

      return zase.b(var1);
   }

   private void b(zcfx var1, SparklineGroup var2) throws Exception {
      if (var2.getVerticalAxisMaxValueType() == 2) {
         var1.a("manualMax", zase.b(var2.getVerticalAxisMaxValue()));
      }

      if (var2.getVerticalAxisMinValueType() == 2) {
         var1.a("manualMin", zase.b(var2.getVerticalAxisMinValue()));
      }

      if (var2.getType() == 0 && var2.getLineWeight() != 0.75D) {
         var1.a("lineWeight", zase.b(var2.getLineWeight()));
      }

      if (var2.getType() != 0) {
         var1.a("type", zase.aB(var2.getType()));
      }

      if (var2.getHorizontalAxisDateRange() != null) {
         var1.a("dateAxis", "1");
      }

      if (var2.getPlotEmptyCellsType() != 1) {
         var1.a("displayEmptyCellsAs", zase.ar(var2.getPlotEmptyCellsType()));
      }

      if (var2.getType() == 0 && var2.getShowMarkers()) {
         var1.a("markers", "1");
      }

      if (var2.getShowHighPoint()) {
         var1.a("high", "1");
      }

      if (var2.getShowLowPoint()) {
         var1.a("low", "1");
      }

      if (var2.getShowFirstPoint()) {
         var1.a("first", "1");
      }

      if (var2.getShowLastPoint()) {
         var1.a("last", "1");
      }

      if (var2.getShowNegativePoints()) {
         var1.a("negative", "1");
      }

      if (var2.getShowHorizontalAxis()) {
         var1.a("displayXAxis", "1");
      }

      if (var2.getDisplayHidden()) {
         var1.a("displayHidden", "1");
      }

      if (var2.getVerticalAxisMinValueType() != 0) {
         var1.a("minAxisType", zase.aC(var2.getVerticalAxisMinValueType()));
      }

      if (var2.getVerticalAxisMaxValueType() != 0) {
         var1.a("maxAxisType", zase.aC(var2.getVerticalAxisMaxValueType()));
      }

      if (var2.getPlotRightToLeft()) {
         var1.a("rightToLeft", "1");
      }

   }
}
